package com.front.managementfront.dictionary.vo;

import com.front.managementfront.dictionary.entity.HktsDictionaryItem;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang.StringUtils;

import java.time.LocalDateTime;

/**
 * @ClassNameDictionaryParamterItemVo
 * @Description
 * @Author yck
 * @Date2021-05-13 20:22
 * @Version V1.0
 **/
@Data
@ApiModel(description = "用于封装字典项禁用，是否热门，顺序请求参数")
public class DictionaryParamterItemVo {
    @ApiModelProperty(value = "主键")
    private String id;
    @ApiModelProperty(value = "是否禁用0否 1禁用" ,required = true)
    private String isDisable;
    @ApiModelProperty(value = "顺序",required = true)
    private Integer itemOrder;
    @ApiModelProperty(value = "值",required = true)
    private String itemValue;
    @ApiModelProperty(value = "字典id",required = true)
    private String listId;
    @ApiModelProperty(value = "单位",required = true)
    private String unit;
    @ApiModelProperty(value = "是否为热门 0 否，1是")
    private String isHotCategories;

    public HktsDictionaryItem getHktsDictionaryItem(DictionaryParamterItemVo vo,HktsDictionaryItem item,String userId ){
        if(StringUtils.isNotBlank(vo.getIsDisable())){
            item.setIsDisable(vo.getIsDisable());
        }
        if(StringUtils.isNotBlank(vo.getIsHotCategories())){
            item.setIsHotCategories(vo.getIsHotCategories());
        }
        if(StringUtils.isNotBlank(vo.getItemValue())){
            item.setItemValue(vo.getItemValue());
        }
        if(vo.getItemOrder()!=null){
            item.setItemOrder(vo.getItemOrder());
        }
        item.setUpdateBy(userId);
        item.setUpdateTime(LocalDateTime.now());
        return item;
    }
}
